#ifndef __THREAD_POOL__
#define __THREAD_POOL__
#include <47func.h>
#include "taskQueue.h"

// switch的标签
typedef enum taskType
{
    CD = 1,
    LS = 2, 
    PUTS = 3,
    GETS = 4,
    REMOVE = 5,
    PWD = 6,
    MKDIR = 7, 
    RMDIR = 8,
    EXIT = 9
} TaskType;

typedef struct msg {
    char command[10];
    int cmdType;
    char arg[100];
} MSG;

// 线程池
typedef struct threadPool_s{
    pthread_t *tidArr;//所有子线程的数组
    int threadNum;//子线程的数量
    taskQueue_t taskQueue;//任务队列
    int exitflag;//退出标志 0 不退出 1 退出
    int taskType;
}threadPool_t;

// 小火车
typedef struct train_s
{
    int length;
    char data[1000];
} train_t;

int makeWorker(threadPool_t *pthreadPool);
void *threadFunc(void *arg);
int threadPoolInit(threadPool_t *pthreadPool,int threadNum);
int tcpInit(const char *ip, const char *port, int *psockfd);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);
int transFile(int netfd, char *filename);
int recvFile(int netfd, char* filename, off_t offset);
int recvCommand(int netfd, char* command);
void getSalt(char *salt, char *pwd);
int pwdCheck(char *user, char *pwd);
off_t getOffset(int netfd, const char *filename);
#endif
